/**
 * form表单组件
 *  zhanghaitao
 */
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import { message } from 'antd';
import { DATA_ENTRY, FormGroup, codeType } from '../../../comps';
import { setFormTime } from '../../../utils/utils';
import myStyle from './index.less';

class FormDaraC extends PureComponent {
  // 默认值
  static defaultProps = {
    onRef: () => {}, // 组件this
    getInfo: () => {}, // 获取表单数据
    init: {}, // 组件回填数据
  };

  state = {
    istwocycleY: true, // 年度计息天数
    isRateUpper: true, // 利率上限是否可编辑
    isMinimumRate: true, // 保底利率是否可编辑
    baseRateWay: '0', // 根据基准利率生效方式判断显示内容
    rzqyshq: false, // 根据含权类型判断是否显示
    tzrhsxzq: false, // 根据含权类型判断是否显示
    isDisable: false, // 根据type类型判断字段是否可编辑
    rateSelect: [], // 评级下拉
    agencyList: [], // 评级机构
    interestRulesList: [], // 计息基础
    isAssure: '', // 是否担保
    twocycle: '',
    financingSelect: [], // 底层融资人融资用途
  };

  componentDidMount() {
    this.props.onRef(this);
    const { init, type } = this.props;
    console.log('init', init);
    console.log('type', type);
    let itemTool = init;
    // 根据type类型判断字段是否可编辑
    if (type == 3 || type == 4 || type == 5) {
      this.setState({ isDisable: true });
    } else {
      this.setState({ isDisable: false });
    }
    if (!itemTool) {
      itemTool = {};
    }
    this.setDefaultData(itemTool);
    const {
      globalM: { dataDictionary = {} },
    } = this.props;
    // 查询评级字典
    this.props.dispatch({
      type: 'moneyInformationM/fetchDictByKeys',
      payload: {
        dictData: dataDictionary,
      },
      callback: (data, agencyList, interestRulesList, financingSelect) => {
        if (data) {
          this.setState({
            rateSelect: data,
            agencyList,
            interestRulesList,
            financingSelect,
          });
        } else {
          this.setState({
            rateSelect: [],
            agencyList: [],
            interestRulesList: [],
            financingSelect: [],
          });
        }
      },
    });
  }

  UNSAFE_componentWillReceiveProps(nextProps) {
    if (JSON.stringify(nextProps.init) != JSON.stringify(this.props.init)) {
      this.setDefaultData(nextProps.init);
    }
  }

  // 设置默认值
  setDefaultData = (itemTool) => {
    // 基准利率生效方式
    if (itemTool.baseRateWay) {
      this.setState({
        baseRateWay: itemTool.baseRateWay,
      });
    }
    // 保底利率是否可编辑
    if (itemTool.isMinimumRate) {
      if (itemTool.isMinimumRate == 0) {
        this.setState({
          isMinimumRate: false,
        });
      } else {
        this.setState({
          isMinimumRate: true,
        });
      }
    }
    // 利率上限是否可编辑
    if (itemTool.isRateUpper) {
      if (itemTool.isRateUpper == 0) {
        this.setState({
          isRateUpper: false,
        });
      } else {
        this.setState({
          isRateUpper: true,
        });
      }
    }
    // 含权类型
    if (itemTool.containType) {
      if (itemTool.containType.indexOf('shq') >= 0) {
        this.setState({
          rzqyshq: true,
        });
      } else {
        this.setState({
          rzqyshq: false,
        });
      }
      if (itemTool.containType.indexOf('hsqzq') >= 0) {
        this.setState({
          tzrhsxzq: true,
        });
      } else {
        this.setState({
          tzrhsxzq: false,
        });
      }
    }
    // 是否担保
    if (itemTool.isAssure) {
      this.setState({
        isAssure: itemTool.isAssure,
      });
    }
    // 计息方式
    if (itemTool.twocycle) {
      this.setState({
        twocycle: itemTool.twocycle,
      });
    }
  };

  // 获取表单数据
  getInfo = () => {
    const {
      form: { validateFields },
    } = this.props;
    const query = this.state.baseInfoRef.getFormGroupData();
    console.log('query', query);
    if (query) {
      if (query.containType) {
        query.containType = query.containType.join(',');
      }
      if (query.guaranteemode) {
        query.guaranteemode = query.guaranteemode.join(',');
      }
      if (query.cashDueDate2) {
        query.cashDueDate2 = query.cashDueDate2.format('YYYYMMDD');
      }
      if (query.hsdjq2) {
        query.hsdjq2 = query.hsdjq2.format('YYYYMMDD');
      }
      if (query.xzqxsr2) {
        query.xzqxsr2 = query.xzqxsr2.format('YYYYMMDD');
      }
      if (query.xzqggr2) {
        query.xzqggr2 = query.xzqggr2.format('YYYYMMDD');
      }
      if (query.finterestDate2) {
        query.finterestDate2 = query.finterestDate2.format('YYYYMMDD');
      }
      if (query.creditRateDate2) {
        query.creditRateDate2 = query.creditRateDate2.format('YYYYMMDD');
      }

      if (query.startingDate2) {
        query.startingDate2 = query.startingDate2.format('YYYYMMDD');
      }
      if (query.enddate2) {
        query.enddate2 = query.enddate2.format('YYYYMMDD');
      }
      if (query.guaranteeEndDate2) {
        query.guaranteeEndDate2 = query.guaranteeEndDate2.format('YYYYMMDD');
      }
      if (query.interestDate2) {
        query.interestDate2 = query.interestDate2.format('YYYYMMDD');
      }

      if (query.noticedate2) {
        query.noticedate2 = query.noticedate2.format('YYYYMMDD');
      }
      if (query.rateDate2) {
        query.rateDate2 = query.rateDate2.format('YYYYMMDD');
      }

      if (query.toolRateDate2) {
        query.toolRateDate2 = query.toolRateDate2.format('YYYYMMDD');
      }
      if (query.payDate2) {
        query.payDate2 = query.payDate2.format('YYYYMMDD');
      }
      if (query.listingdate2) {
        query.listingdate2 = query.listingdate2.format('YYYYMMDD');
      }
      // 发行开始日<发行结束日
      if (query.startingDate2 > query.enddate2) {
        message.error('发型结束日要大于发型开始日！');
        return;
      }
    }
    return query;
  };

  // 基准利率生效方式回调
  onChangeBaseRateWay = (e) => {
    this.setState({
      baseRateWay: e,
    });
  };

  // 是否有保底利率回调
  onChangeMinimumRate = (e) => {
    let y = true;
    if ('0' === e) {
      y = false;
    }
    if (y) {
      const { form } = this.props;
      form.resetFields(['minimumRate']);
      form.setFieldsValue({ minimumRate: '' });
    }
    this.setState({
      isMinimumRate: y,
    });
  };

  // 是否有利率上限
  onChangeRateUpper = (e) => {
    let y = true;
    if ('0' == e) {
      y = false;
    }
    if (y) {
      const { form } = this.props;
      form.setFieldsValue({ rateUpper: '' });
    }
    this.setState({
      isRateUpper: y,
    });
  };

  // 含权类型多选框触发事件
  containtype = (checkedValues) => {
    let str = '';
    for (let i = 0; i < checkedValues.length; i++) {
      str += `${checkedValues[i]},`;
    }
    if (str.lastIndexOf(',') > 0) {
      str = str.substring(0, str.lastIndexOf(','));
    }
    if (str) {
      if (str.indexOf('shq') >= 0) {
        this.setState({
          rzqyshq: true,
        });
      } else {
        this.setState({
          rzqyshq: false,
        });
      }
      if (str.indexOf('hsqzq') >= 0) {
        this.setState({
          tzrhsxzq: true,
        });
      } else {
        this.setState({
          tzrhsxzq: false,
        });
      }
    } else {
      this.setState({
        tzrhsxzq: false,
        rzqyshq: false,
      });
    }
  };

  // 证券代码改变响应
  secucodeChange = (e) => {
    this.props.secucodeChange(e);
  };

  onChangeAssure = (e) => {
    this.setState({
      isAssure: e,
    });
  };

  onChangTwocycle = (e) => {
    this.setState(
      {
        twocycle: e,
      },
      () => {
        const query = this.state.baseInfoRef;
        this.props?.onBaseInfoChange({
          interestMethod: e,
          fixedRate: query.getFieldValue('couponRate'),
          interestBasis: query.getFieldValue('interestRules'),
          interestRate: query.getFieldValue('interestFrequency'),
        });
      },
    );
  };

  render() {
    const {
      type,
      init,
      form: { getFieldsValue, getFieldDecorator },
    } = this.props;
    const { isDisable, rateSelect, agencyList, isAssure, twocycle, baseRateWay, rzqyshq, tzrhsxzq, interestRulesList, financingSelect } = this.state;
    let itemTool = init;
    if (!itemTool) {
      itemTool = {};
    }
    // 含权类型
    const options2 = [
      { title: '融资企业赎回权', value: 'shq' },
      { title: '投资人回售选择权', value: 'hsqzq' },
      { title: '融资企业上调票面利率选择权', value: 'pmllxzq' },
      { title: '融资企业合并工具选择权', value: 'hbgzxzq' },
      { title: '投资人调换工具选择权', value: 'thgzxzq' },
      { title: '融资企业/投资人递延兑付选择权', value: 'dydfxzq' },
      { title: '投资人定向转让选择权', value: 'dxzrxzq' },
      { title: '其他选择权', value: 'qtxzq' },
    ];
    // 担保方式
    const options = [
      { title: '担保或保证', value: 'db' },
      { title: '质押', value: 'zy' },
      { title: '抵押', value: 'dy' },
      { title: '其他', value: 'qt' },
    ];
    const { istwocycleY } = this.state;
    let istwocycleY2 = istwocycleY;
    const pp = getFieldsValue();
    if ('360' === pp.twocycleY) {
      istwocycleY2 = false;
    }
    // 是否为城投企业
    const isCityData = [
      { title: '否', value: '0' },
      { title: '是', value: '1' },
    ];
    // 期限单位
    const companyData = [
      { title: '年', value: 'Y' },
      { title: '月', value: 'M' },
      { title: '日', value: 'D' },
    ];
    // 担保企业是否为城投
    const isGuaranteeCityData = [
      { title: '否', value: '0' },
      { title: '是', value: '1' },
    ];
    // 计息方式
    const twocycleData = [
      { title: '贴现式', value: 'txs' },
      { title: '零息式', value: 'lxs' },
      { title: '利随本清式', value: 'lsbqs' },
      { title: '附息式固定利率', value: 'fxsgdlv' },
      { title: '附息式浮动利率', value: 'fxsfdlv' },
      { title: '无', value: 'w' },
    ];
    // 利息分配方式
    const interestDistriData = [
      { title: '平均分配', value: '0' },
      { title: '按实际天数分配', value: '1' },
    ];
    // 工具现金流是否规则
    const isRuleData = [
      { title: '规则', value: '0' },
      { title: '不规则', value: '1' },
    ];
    // 是否有利率上限
    const isRateUpperData = [
      { title: '是', value: '0' },
      { title: '否', value: '1' },
    ];
    // 基准利率生效方式
    const baseRateWayData = [
      { title: '付息后生效', value: '0' },
      { title: '当期生效', value: '1' },
      { title: '按指定条件生效', value: '2' },
    ];
    return (
      <FormGroup
        onRef={(ref) => {
          this.state.baseInfoRef = ref;
        }}
        rowNumber={3}
        autoLayout={false}
        dataSource={[
          {
            dataIndex: 'secucode1',
            title: '证券代码',
            type: DATA_ENTRY.SECURITIESCODE,
            initialValue: itemTool.secucode ? itemTool.secucode : undefined,
            codeType: codeType.lczr,
            onChange: (e) => {
              this.secucodeChange(e);
            },
            rules: [{ required: true, message: '请输入证券代码' }],
            hide: type != 4,
          },
          {
            dataIndex: 'secucode',
            title: '证券代码',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.secucode ? itemTool.secucode : undefined,
            rules: [{ required: true, message: '请输入证券代码' }],
            hide: type == 4,
            disabled: type != 1,
          },
          {
            dataIndex: 'chiname',
            title: '证券全称',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.chiname ? itemTool.chiname : '',
            rules: [{ required: true, message: '请输入证券名称' }],
            disabled: isDisable,
          },
          {
            dataIndex: 'secuabbr',
            title: '证券简称',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.secuabbr ? itemTool.secuabbr : '',
            rules: [{ required: true, message: '请输入证券名称（简称）' }],
            disabled: isDisable,
          },
          {
            dataIndex: 'tradingMarket',
            type: DATA_ENTRY.TRADINGMARKET,
            dataType: 2,
            initialValue: 'C',
            marketType: ['cw'],
            rules: [{ required: true, message: '请选择交易市场' }],
            disabled: true,
          },
          {
            dataIndex: 'financeName',
            title: '融资人',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.financeName ? itemTool.financeName : '',
            rules: [
              {
                required: true,
                message: '请输入融资人',
              },
            ],
            disabled: isDisable,
          },
          {
            dataIndex: 'financeTrade',
            title: '融资人所属行业',
            type: DATA_ENTRY.FUNDAPPLICATIONINDUSTRYC,
            initialValue: itemTool.financeTrade ? itemTool.financeTrade : '',
            optionTitle: true,
            disabled: isDisable,
            allowClear: true,
          },
          {
            type: DATA_ENTRY.ADDRESSC,
            provinceDataIndex: 'financeLocationProvince',
            cityDataIndex: 'financeLocationCity',
            provInit: itemTool?.financeLocationProvince,
            provinceDataTitle: '融资企业所在省',
            cityDataTitle: '融资企业所在市',
            cityInit: itemTool?.financeLocationCity,
            disabled: isDisable,
            allowClear: true,
          },
          {
            dataIndex: 'isCity',
            title: '是否为城投企业',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.isCity ? itemTool.isCity : '',
            showSearch: false,
            optionTitle: true,
            disabled: isDisable,
            dataSource: isCityData,
          },
          {
            dataIndex: 'term',
            title: '期限',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.term ? itemTool.term : '',
            rules: [{ required: true, message: '请输入期限' }],
            disabled: isDisable,
            min: 0,
          },
          {
            dataIndex: 'company',
            title: '期限单位',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.company ? itemTool.company : '',
            showSearch: false,
            optionTitle: true,
            disabled: isDisable,
            rules: [{ required: true, message: '请选择期限单位' }],
            dataSource: companyData,
          },
          {
            dataIndex: 'total',
            title: '计划发行规模',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.total ? itemTool.total : '',
            rules: [{ pattern: /^[0-9]/, message: '数量不能小于0' }],
            disabled: isDisable,
            splitStyle: true,
            precision: 2,
            unit: '万元',
          },
          {
            dataIndex: 'actualTotal',
            title: '实际发行规模',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.actualTotal ? itemTool.actualTotal : '',
            rules: [{ pattern: /^[0-9]/, message: '数量不能小于0' }],
            disabled: isDisable,
            splitStyle: true,
            precision: 2,
            unit: '万元',
          },
          {
            dataIndex: 'issueprice',
            title: '发行价格',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.issueprice ? itemTool.issueprice : '',
            rules: [
              { pattern: /^[0-9]/, message: '数量不能小于0' },
              { required: true, message: '请输入发行价格' },
            ],
            disabled: isDisable,
            splitStyle: true,
            onChange: (e) => {
              this.props?.onBaseInfoChange({ parTotalValue: e });
            },
            precision: 2,
            unit: '元',
          },
          {
            dataIndex: 'interestDate2',
            title: '起息日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.interestDate),
            rules: [{ required: true, message: '请选择起息日' }],
            onChange: (e) => {
              this.props?.onBaseInfoChange({ startDate: e });
            },
            disabled: isDisable,
          },
          {
            dataIndex: 'cashDueDate2',
            title: '到期日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.cashDueDate),
            rules: [{ required: true, message: '请选择到期日' }],
            onChange: (e) => {
              this.props?.onBaseInfoChange({ endDate: e });
            },
            disabled: isDisable,
          },
          {
            dataIndex: 'startingDate2',
            title: '发行开始日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.startingDate),
            disabled: isDisable,
          },
          {
            dataIndex: 'enddate2',
            title: '发行结束日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.enddate),
            disabled: isDisable,
          },
          {
            dataIndex: 'noticedate2',
            title: '公告日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.noticedate),
            disabled: isDisable,
          },
          {
            dataIndex: 'payDate2',
            title: '认购缴款日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.payDate),
            disabled: isDisable,
          },
          {
            dataIndex: 'listingdate2',
            title: '上市流通日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.listingdate),
            disabled: isDisable,
          },
          {
            dataIndex: 'rate',
            title: '融资人主体评级',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.rate ? itemTool.rate : '',
            showSearch: false,
            optionTitle: true,
            allowClear: true,
            disabled: isDisable,
            dataSource: rateSelect,
          },
          {
            dataIndex: 'rateOrgan',
            title: '主体评级机构',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.rateOrgan ? itemTool.rateOrgan : '',
            disabled: isDisable,
            allowClear: true,
            dataSource: agencyList.slice(4),
          },
          {
            dataIndex: 'rateDate2',
            title: '主体评级日期',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.rateDate),
            disabled: isDisable,
          },
          {
            dataIndex: 'toolRate',
            title: '资产评级',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.toolRate ? itemTool.toolRate : '',
            showSearch: false,
            optionTitle: true,
            disabled: isDisable,
            allowClear: true,
            dataSource: rateSelect,
          },
          {
            dataIndex: 'toolRateSECUABBR',
            title: '资产评级机构',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.toolRateSECUABBR ? itemTool.toolRateSECUABBR : '',
            allowClear: true,
            disabled: isDisable,
            dataSource: agencyList.slice(4),
          },
          {
            dataIndex: 'toolRateDate2',
            title: '资产评级日期',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.toolRateDate),
            disabled: isDisable,
          },
          {
            dataIndex: 'creditRate',
            title: '增信后资产评级',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.creditRate ? itemTool.creditRate : '',
            showSearch: false,
            optionTitle: true,
            allowClear: true,
            disabled: isDisable,
            dataSource: rateSelect,
          },
          {
            dataIndex: 'creditRateDate2',
            title: '增信评级日期',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.creditRateDate),
            disabled: isDisable,
          },
          {
            dataIndex: 'isAssure',
            title: '是否担保',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.isAssure ? itemTool.isAssure : '',
            disabled: isDisable,
            isTrueFalseJudge: true,
            onChange: (e) => this.onChangeAssure(e),
            rules: [{ required: true, message: '请选择是否担保' }],
          },
          {
            dataIndex: 'guaranteemode',
            title: '担保方式',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.guaranteemode ? itemTool.guaranteemode.split(',') : [],
            showSearch: false,
            optionTitle: true,
            disabled: isDisable,
            isMultiple: true,
            maxTagCount: 0,
            rules: [{ required: isAssure == '1', message: '请选择担保方式' }],
            dataSource: options,
            hide: isAssure != '1',
          },
          {
            dataIndex: 'guaranteeName',
            title: '担保机构名称',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.guaranteeName ? itemTool.guaranteeName : '',
            allowClear: true,
            hide: isAssure != '1',
            disabled: isDisable,
          },
          {
            dataIndex: 'guaranteeCredit',
            title: '担保机构信用级别',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.guaranteeCredit ? itemTool.guaranteeCredit : '',
            allowClear: true,
            hide: isAssure != '1',
            disabled: isDisable,
          },
          ...(isAssure == 1
            ? [
                {
                  type: DATA_ENTRY.ADDRESSC,
                  provinceDataIndex: 'guaranteeLocationProvince',
                  cityDataIndex: 'guaranteeLocationCity',
                  provInit: itemTool?.guaranteeLocationProvince,
                  provinceDataTitle: '担保企业所在省',
                  cityDataTitle: '担保企业所在市',
                  cityInit: itemTool?.guaranteeLocationCity,
                  disabled: isDisable,
                  allowClear: true,
                  // formItemLayout: formItemLayout,
                },
              ]
            : []),
          {
            dataIndex: 'guaranteeTrade',
            title: '担保机构所属行业',
            type: DATA_ENTRY.FUNDAPPLICATIONINDUSTRYC,
            initialValue: itemTool.guaranteeTrade ? itemTool.guaranteeTrade : '',
            disabled: isDisable,
            allowClear: true,
            hide: isAssure != '1',
            optionTitle: true,
          },
          {
            dataIndex: 'isGuaranteeCity',
            title: '担保企业是否为城投',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.isGuaranteeCity ? itemTool.isGuaranteeCity : '',
            allowClear: true,
            showSearch: false,
            optionTitle: true,
            disabled: isDisable,
            hide: isAssure != '1',
            dataSource: isGuaranteeCityData,
          },
          {
            dataIndex: 'guaranteeSecuabbr',
            title: '担保券简称',
            allowClear: true,
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.guaranteeSecuabbr ? itemTool.guaranteeSecuabbr : '',
            hide: isAssure != '1',
            disabled: isDisable,
          },
          {
            dataIndex: 'guaranteeSecucode',
            title: '担保券代码',
            allowClear: true,
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.guaranteeSecucode ? itemTool.guaranteeSecucode : '',
            hide: isAssure != '1',
            disabled: isDisable,
          },
          {
            dataIndex: 'guaranteeEndDate2',
            title: '担保券到期日',
            type: DATA_ENTRY.SINGLEDATE,
            initialValue: setFormTime(itemTool.guaranteeEndDate),
            disabled: isDisable,
            hide: isAssure != '1',
          },
          {
            dataIndex: 'guaranteeissuer',
            title: '担保券发行人',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.guaranteeissuer ? itemTool.guaranteeissuer : '',
            hide: isAssure != '1',
            allowClear: true,
            disabled: isDisable,
          },
          {
            dataIndex: 'twocycle',
            title: '计息方式',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.twocycle ? itemTool.twocycle : '',
            showSearch: false,
            optionTitle: true,
            disabled: isDisable,
            dataSource: twocycleData,
            rules: [{ required: true, message: '请选择计息方式' }],
            onChange: (e) => {
              this.onChangTwocycle(e);
            },
          },
          {
            dataIndex: 'couponRate',
            title: '票面利率',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.couponRate ? itemTool.couponRate : '',
            rules: [
              { pattern: /^[0-9]/, message: '利率不能小于0' },
              { required: twocycle == 'lsbqs' || twocycle == 'fxsgdlv', message: '请输入票面利率' },
            ],
            disabled: isDisable,
            splitStyle: true,
            precision: 2,
            unit: '%',
            hide: twocycle != 'lsbqs' && twocycle != 'fxsgdlv',
            onChange: (e) => {
              this.props?.onBaseInfoChange({ fixedRate: e });
            },
          },
          {
            dataIndex: 'interestRules',
            title: '计息基础',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.interestRules ? itemTool.interestRules : '',
            disabled: isDisable,
            hide: twocycle != 'fxsfdlv' && twocycle != 'fxsgdlv' && twocycle != 'lsbqs',
            dataSource: interestRulesList,
            onChange: (e) => {
              this.props?.onBaseInfoChange({ interestBasis: e });
            },
            rules: [{ required: twocycle == 'fxsfdlv' || twocycle == 'fxsgdlv' || twocycle == 'lsbqs', message: '请选择计息基础' }],
          },
          {
            dataIndex: 'interestFrequency',
            title: '计息频率',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.interestFrequency ? itemTool.interestFrequency : '',
            rules: [{ required: twocycle == 'fxsfdlv' || twocycle == 'fxsgdlv', message: '请输入计息频率' }],
            disabled: isDisable,
            precision: 0,
            max: 10000,
            min: 1,
            unit: '次/年',
            onChange: (e) => {
              this.props?.onBaseInfoChange({ interestRate: e });
            },
            hide: twocycle != 'fxsfdlv' && twocycle != 'fxsgdlv',
          },
          {
            dataIndex: 'interestDistri',
            title: '利息分配方式',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.interestDistri ? itemTool.interestDistri : '',
            disabled: isDisable,
            hide: twocycle != 'fxsfdlv' && twocycle != 'fxsgdlv',
            dataSource: interestDistriData,
            allowClear: true,
            optionTitle: true,
            showSearch: false,
          },
          {
            dataIndex: 'isRule',
            title: '现金流是否规则',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.isRule ? itemTool.isRule : '',
            disabled: isDisable,
            hide: twocycle != 'fxsfdlv' && twocycle != 'fxsgdlv',
            dataSource: isRuleData,
            allowClear: true,
            optionTitle: true,
            showSearch: false,
          },
          {
            dataIndex: 'baseRate',
            title: '基准利率',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.baseRate ? itemTool.baseRate : '',
            rules: [
              { pattern: /^[0-9]/, message: '利率不能小于0' },
              { required: twocycle == 'fxsfdlv', message: '请输入基准利率' },
            ],
            disabled: isDisable,
            precision: 2,
            splitStyle: true,
            unit: '%',
            hide: twocycle != 'fxsfdlv',
          },
          {
            dataIndex: 'rateKind',
            title: '基准利率种类名称',
            type: DATA_ENTRY.INPUT,
            initialValue: itemTool.rateKind ? itemTool.rateKind : '',
            hide: twocycle != 'fxsfdlv',
            rules: [{ required: twocycle == 'fxsfdlv', message: '请输入基准利率种类名称' }],
            disabled: isDisable,
          },
          {
            dataIndex: 'issueMargin',
            title: '发行时利差',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.issueMargin ? itemTool.issueMargin : '',
            rules: [
              { pattern: /^[0-9]/, message: '利率不能小于0' },
              { required: twocycle == 'fxsfdlv', message: '请输入发行时利差' },
            ],
            disabled: isDisable,
            precision: 2,
            splitStyle: true,
            unit: '%',
            hide: twocycle != 'fxsfdlv',
          },
          {
            dataIndex: 'isRateUpper',
            title: '是否有利率上限',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.isRateUpper ? itemTool.isRateUpper : '',
            disabled: isDisable,
            hide: twocycle != 'fxsfdlv',
            dataSource: isRateUpperData,
            optionTitle: true,
            onChange: (e) => this.onChangeRateUpper(e),
            showSearch: false,
            rules: [{ required: twocycle == 'fxsfdlv', message: '请选择是否有利率上限' }],
          },
          {
            dataIndex: 'rateUpper',
            title: '利率上限',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.rateUpper ? itemTool.rateUpper : '',
            rules: [
              { pattern: /^[0-9]/, message: '利率不能小于0' },
              { required: !this.state.isRateUpper, message: '请输入利率上限' },
            ],
            disabled: this.state.isRateUpper ? this.state.isRateUpper : isDisable,
            precision: 2,
            splitStyle: true,
            unit: '%',
            hide: twocycle != 'fxsfdlv' || this.state.isRateUpper,
          },
          {
            dataIndex: 'isMinimumRate',
            title: '是否有保底利率',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.isMinimumRate ? itemTool.isMinimumRate : '',
            disabled: isDisable,
            hide: twocycle != 'fxsfdlv',
            dataSource: isRateUpperData,
            optionTitle: true,
            onChange: (e) => this.onChangeMinimumRate(e),
            showSearch: false,
            rules: [{ required: twocycle == 'fxsfdlv', message: '请选择是否有保底利率' }],
          },
          {
            dataIndex: 'minimumRate',
            title: '保底利率',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: itemTool.minimumRate ? itemTool.minimumRate : '',
            rules: [
              { pattern: /^[0-9]/, message: '利率不能小于0' },
              { required: !this.state.isMinimumRate, message: '请输入利率上限' },
            ],
            disabled: this.state.isMinimumRate ? this.state.isMinimumRate : isDisable,
            precision: 2,
            splitStyle: true,
            unit: '%',
            hide: twocycle != 'fxsfdlv' || this.state.isMinimumRate,
          },
          {
            dataIndex: 'baseRateWay',
            title: '基准利率生效方式',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.baseRateWay ? itemTool.baseRateWay : '',
            disabled: isDisable,
            hide: twocycle != 'fxsfdlv',
            dataSource: baseRateWayData,
            optionTitle: true,
            onChange: (e) => this.onChangeBaseRateWay(e),
            showSearch: false,
            rules: [{ required: twocycle == 'fxsfdlv', message: '请选择基准利率生效方式' }],
          },
          ...(baseRateWay == 0
            ? [
                {
                  dataIndex: 'takeDate',
                  title: '生效时期',
                  type: DATA_ENTRY.SELECT,
                  initialValue: itemTool.takeDate ? itemTool.takeDate : '',
                  disabled: isDisable,
                  hide: twocycle != 'fxsfdlv',
                  dataSource: [
                    { title: '计息期有效', value: '0' },
                    { title: '计息年度有效', value: '1' },
                  ],
                  optionTitle: true,
                  showSearch: false,
                  rules: [{ required: twocycle == 'fxsfdlv', message: '请选择生效时期' }],
                },
              ]
            : []),
          ...(baseRateWay == 2
            ? [
                {
                  dataIndex: 'takeCondition',
                  title: '生效条件',
                  type: DATA_ENTRY.SELECT,
                  initialValue: itemTool.takeCondition ? itemTool.takeCondition : '0',
                  disabled: isDisable,
                  hide: twocycle != 'fxsfdlv',
                  dataSource: [
                    { title: '基准利率变动后固定间隔时间生效', value: '0' },
                    { title: '付息前指定日期的有效基准利率', value: '1' },
                  ],
                  optionTitle: true,
                  showSearch: false,
                  rules: [{ required: twocycle == 'fxsfdlv', message: '请选择生效时期' }],
                },
              ]
            : []),
          {
            dataIndex: 'containType',
            title: '含权类型',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.containType ? itemTool.containType.split(',') : [],
            disabled: isDisable,
            dataSource: options2,
            allowClear: true,
            optionTitle: true,
            isMultiple: true,
            maxTagCount: 0,
            onChange: (e) => this.containtype(e),
            showSearch: false,
          },
          ...(rzqyshq
            ? [
                {
                  dataIndex: 'xzqggr2',
                  title: '选择权公告日',
                  type: DATA_ENTRY.SINGLEDATE,
                  initialValue: setFormTime(itemTool.xzqggr),
                  disabled: isDisable,
                },
                {
                  dataIndex: 'shjg',
                  title: '赎回价格',
                  type: DATA_ENTRY.INPUTNUMBER,
                  initialValue: itemTool.shjg ? itemTool.shjg : '',
                  rules: [{ pattern: /^[0-9]/, message: '价格不能小于0' }],
                  disabled: isDisable,
                  precision: 2,
                  splitStyle: true,
                  unit: '元',
                },
                {
                  dataIndex: 'xzqxsr2',
                  title: '选择权行使日',
                  type: DATA_ENTRY.SINGLEDATE,
                  initialValue: setFormTime(itemTool.xzqxsr),
                  disabled: isDisable,
                },
                {
                  dataIndex: 'hjnlllc',
                  title: '后几年工具的利率或利差',
                  type: DATA_ENTRY.INPUTNUMBER,
                  initialValue: itemTool.hjnlllc ? itemTool.hjnlllc : '',
                  rules: [{ pattern: /^[0-9]/, message: '利率不能小于0' }],
                  disabled: isDisable,
                  precision: 2,
                  splitStyle: true,
                  unit: '%',
                },
              ]
            : []),
          ...(tzrhsxzq
            ? [
                {
                  dataIndex: 'hsdjq2',
                  title: '回售登记期',
                  type: DATA_ENTRY.SINGLEDATE,
                  initialValue: setFormTime(itemTool.hsdjq),
                  disabled: isDisable,
                },
                {
                  dataIndex: 'hsjg',
                  title: '回售价格',
                  type: DATA_ENTRY.INPUTNUMBER,
                  initialValue: itemTool.hsjg ? itemTool.hsjg : '',
                  rules: [{ pattern: /^[+-]?(\d){1,}00$/, message: '请输入100的倍数' }],
                  disabled: isDisable,
                  precision: 2,
                  splitStyle: true,
                  unit: '元',
                },
                {
                  dataIndex: 'xzqcftj',
                  title: '选择权行使触发条件',
                  type: DATA_ENTRY.SELECT,
                  showSearch: false,
                  disabled: isDisable,
                  initialValue: itemTool.xzqcftj ? itemTool.xzqcftj : '0',
                  dataSource: [
                    { title: '有', value: '0' },
                    { title: '无', value: '1' },
                  ],
                  optionTitle: true,
                },
              ]
            : []),
          {
            dataIndex: 'underlyingFinanciers',
            title: '底层融资人融资用途',
            type: DATA_ENTRY.SELECT,
            initialValue: itemTool.underlyingFinanciers ? itemTool.underlyingFinanciers : '',
            showSearch: false,
            optionTitle: true,
            allowClear: true,
            disabled: isDisable,
            dataSource: financingSelect,
            rules: [{ required: true, message: '请选择底层融资人融资用途' }],
          },
        ]}
      />
    );
  }
}

// props默认值
FormDaraC.propsTypes = {
  type: PropTypes.string || PropTypes.number, // 1-新建   2-编辑    3-转换前    4-转换后    5-查看
  onRef: () => {}, // 组件this
  getInfo: () => {}, // 获取表单数据
  init: {}, // 组件回填数据
};
export default connect(({ moneyInformationM, loading, globalM }) => ({
  moneyInformationM,
  loading,
  globalM,
}))(FormDaraC);
